package com.cwj.lab4.SORT;

import com.cwj.lab1.myArrayList;

import java.util.Arrays;

/**
 * 排序的测试代码
 */
public class TestSort {
    public static void main(String[] args) {
        TestSort.sortTest();
    }

    static void sortTest() {
        myArrayList<Sorted<Integer>> list = new myArrayList<>();
        list.addLast(new BubbleSort<Integer>());
        list.addLast(new HeapSort<>());
        list.addLast(new insertSort<>());
        list.addLast(new mergeSort<>());
        list.addLast(new quickSort<>());
        list.addLast(new XESort<>());
        for (int i = 0; i < list.size(); i++) {
            test(list.get(i), 15);
        }
    }

    static void test(Sorted<Integer> ss, int size) {
        System.out.println(ss.getClass().getSimpleName());
        Integer[] nums = new Integer[size];
        for (int i = 0; i < size; i++) {
            nums[i] = (int) (Math.random() * 50);
        }
        System.out.println("原数组：" + Arrays.toString(nums));
        ss.Sort(nums);
        System.out.println("排序后数组：" + Arrays.toString(nums));
    }
}
